# 字典是一个无序的结构!!!  所有的序列是一个有序结构!!!
# 无序和有序的最大区别: 能否通过索引去取值

# 1.字典的定义 (键值对)
# {key:value}  key建议使用字符串,value可以是任意类型!
# dict_01 = {"name":"damu","id":371083712073102931}

# 2. 通过字典的key去取value
# name = dict_01["name"]
# print(name)

# 3. 字典的一些常用操作
# in , not in
# len()
# print("name" in dict_01)
# print(len(dict_01))

# 4. 如何遍历字典
dict_01 = {"name":"damu","id":371083712073102931}
# for key in dict_01:
#     print(key)
#
# for key in dict_01:
#     value = dict_01[key]
#     print(key,value)

for key in dict_01.keys():
    print(key)

for value in dict_01.values():
    print(value)

for key,value in dict_01.items():
    print(key,value)

# 5. 字典的常用方法
# CRUD

# C:create 新增
# dict_01 = {"name":"damu"}
# dict_01["age"] = 18
# print(dict_01)

# U:update 修改
# dict_01["age"] = 28
# print(dict_01)

# dict_01.update({"age":38})
# print(dict_01)

# D:delete 删除
# dict_01.pop("age")
# print(dict_01)

# del dict_01["name"]
# print(dict_01)
#
# dict_01.clear()
# print(dict_01)


# R:read 读取
dict_01 = {"name":"damu","id":371083712073102931}
# print(list(dict_01.keys()))

# print(list(dict_01.values()))

# print(list(dict_01.items()))








